package com.cate.utils;

import org.jasypt.util.password.PasswordEncryptor;
import org.jasypt.util.password.StrongPasswordEncryptor;


/**
 * @CreateTime: 2023/7/27
 * @Author: <==lhd==>
 * @Description: 密码加密
 */

public class JasyptUtil {

    private static final PasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();

    /**
     * 加密密码
     *
     * @param password  -密码原文
     * @return          -返回密码密文
     */
    public static String encryptPassword(String password){
        return passwordEncryptor.encryptPassword(password);
    }

    /**
     * 比较 密码密文与密码原文
     *
     * @param plainPassword     - 密码明文
     * @param encryptPassword   - 密码密文
     * @return                  - 明文和密文是否一致
     */
    public static boolean checkPassword(String plainPassword, String encryptPassword){
        return passwordEncryptor.checkPassword(plainPassword,encryptPassword);
    }


}
